package tw.asap.plus.entity.response;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * Created:      [15/12/29]
 * Author:       [Yang]
 **/
public class GoodsDetailNV implements Parcelable {

    /**
     * price_init : 商品原价
     * unit : 单位
     * sales_nums : 已售数量
     * props : [{"propkey_id":"商品属性id (int)","name":"商品属性名字, 如: 风味","values":[{"value":"商品属性值,　如: 加冰","propvalue_id":"属性值id (int)"}]}]
     * price : 商品现价
     * title : 商品名称
     * bgimg : 商品图片
     * intro : 商品介绍
     * url : 图文详情链接
     */

    private String price_init;
    private String unit;
    private String sales_nums;
    private String price;
    private String title;
    private String bgimg;
    private String intro;
    private String url;
    /**
     * propkey_id : 商品属性id (int)
     * name : 商品属性名字, 如: 风味
     * values : [{"value":"商品属性值,　如: 加冰","propvalue_id":"属性值id (int)"}]
     */

    private List<PropsEntity> props;

    public void setPrice_init(String price_init) {
        this.price_init = price_init;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public void setSales_nums(String sales_nums) {
        this.sales_nums = sales_nums;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setBgimg(String bgimg) {
        this.bgimg = bgimg;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public void setProps(List<PropsEntity> props) {
        this.props = props;
    }

    public String getPrice_init() {
        return price_init;
    }

    public String getUnit() {
        return unit;
    }

    public String getSales_nums() {
        return sales_nums;
    }

    public String getPrice() {
        return price;
    }

    public String getTitle() {
        return title;
    }

    public String getBgimg() {
        return bgimg;
    }

    public String getIntro() {
        return intro;
    }

    public String getUrl() {
        return url;
    }

    public List<PropsEntity> getProps() {
        return props;
    }

    public static class PropsEntity {
        private String propkey_id;
        private String name;
        /**
         * value : 商品属性值,　如: 加冰
         * propvalue_id : 属性值id (int)
         */

        private List<ValuesEntity> values;

        public void setPropkey_id(String propkey_id) {
            this.propkey_id = propkey_id;
        }

        public void setName(String name) {
            this.name = name;
        }

        public void setValues(List<ValuesEntity> values) {
            this.values = values;
        }

        public String getPropkey_id() {
            return propkey_id;
        }

        public String getName() {
            return name;
        }

        public List<ValuesEntity> getValues() {
            return values;
        }

        public static class ValuesEntity implements Serializable {

            private String value;
            private String propvalue_id;

            public void setValue(String value) {
                this.value = value;
            }

            public void setPropvalue_id(String propvalue_id) {
                this.propvalue_id = propvalue_id;
            }

            public String getValue() {
                return value;
            }

            public String getPropvalue_id() {
                return propvalue_id;
            }

            @Override
            public boolean equals(Object o) {
                return o instanceof ValuesEntity && value.equals(((ValuesEntity) o).getValue()) && propvalue_id.equals(((ValuesEntity) o).getPropvalue_id());
            }
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.price_init);
        dest.writeString(this.unit);
        dest.writeString(this.sales_nums);
        dest.writeString(this.price);
        dest.writeString(this.title);
        dest.writeString(this.bgimg);
        dest.writeString(this.intro);
        dest.writeString(this.url);
        dest.writeList(this.props);
    }

    public GoodsDetailNV() {
    }

    protected GoodsDetailNV(Parcel in) {
        this.price_init = in.readString();
        this.unit = in.readString();
        this.sales_nums = in.readString();
        this.price = in.readString();
        this.title = in.readString();
        this.bgimg = in.readString();
        this.intro = in.readString();
        this.url = in.readString();
        this.props = new ArrayList<PropsEntity>();
        in.readList(this.props, List.class.getClassLoader());
    }

    public static final Parcelable.Creator<GoodsDetailNV> CREATOR = new Parcelable.Creator<GoodsDetailNV>() {
        public GoodsDetailNV createFromParcel(Parcel source) {
            return new GoodsDetailNV(source);
        }

        public GoodsDetailNV[] newArray(int size) {
            return new GoodsDetailNV[size];
        }
    };
}
